package com.zut.view;

import com.zut.entity.Manager;
import com.zut.service.ManagerService;
import com.zut.service.impl.ManagerServiceImpl;

import java.util.Scanner;

public class MangerView {
    private Scanner sc = new Scanner(System.in);

    //管理员业务对象
    private ManagerService ms = new ManagerServiceImpl();


    /**
     * 修改登录的管理员密码
     * @param loginUser
     */
    public void updatePsswordPage(Manager loginUser) {


        while (true){
            System.out.println("请输入原密码：");
            String oldPwd = sc.nextLine();

            if(oldPwd.equals(loginUser.getPassword())){

                System.out.println("请输入新密码:");
                String newPwd = sc.nextLine();

                //调用修改密码的业务方法
                ms.updatePassword(loginUser.getUsername(),newPwd);
                return;
            }else{
                System.out.println("原密码不正确，请重新输入");
            }

        }

    }
}
